export default (config, formObjName = 'form') => {
  return config
    .map(({ name, chineseName, lang, prop = false, span = 6, disabled = false, type = 'input', selectOption, searchType = 'group_code' }) => {
      let inputType = ''
      lang = lang ? lang : `erp.financial.${name}`
      switch (type) {
        case 'input':
          inputType = `<el-input v-model="${formObjName}.${name}" ${disabled ? 'disabled' : ''}></el-input>`
          break
        case 'date':
          inputType = `<el-date-picker v-model="${formObjName}.${name}" type="date" ${disabled ? 'disabled' : ''}></el-date-picker>`
          break
        case 'search':
          inputType = `<bpt-dialog v-model="${formObjName}.${name}" :dialog-type="'${searchType}'" @dialogFun="''"/>`
          break
        case 'select':
          let option = ''
          if (selectOption) {
            selectOption.forEach(item => {
              option += `<el-option label="${item}" value="${item}"></el-option>`
            })
          } else {
            option = `<el-option label="" value=""></el-option>`
          }
          inputType = ` 
                <el-select v-model="${formObjName}.${name}" ${disabled ? 'disabled' : ''}>
                    ${option}
                </el-select>   
            `
          break
        default:
          break
      }
      return `
        <!-- ${chineseName} -->
        <el-col :span="${span}">
            <el-form-item :label="$t('${lang}')" ${prop ? `prop="${name}"` : ''}>
              ${inputType}
            </el-form-item>
        </el-col>
    `
    })
    .join(' ')
}
